//开发人员相关操作
import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";
import { type PaginationProps } from "@pureadmin/table";
/** 获取开发人员列表 */

type resultAPI = {
  isSuccess?: boolean;
  msg?: string;
  pageInfo?: object;
  result?: Array<any>;
  onePage?: PaginationProps;
};

//获得元表类型列表
export const getMetaTableList = (params?: object) => {
  return http.request<resultAPI>(
    "post",
    baseUrlApi("MetaTable/getAllTableClass"),
    {
      params
    }
  );
};

//保存一个类别
export const saveClass = (data?: object) => {
  return http.request<resultAPI>(
    "post",
    baseUrlApi("MetaTable/saveTableClass"),
    {
      data
    }
  );
};

//删除一个类别
export const deleteClass = (params?: object) => {
  return http.request<resultAPI>(
    "post",
    baseUrlApi("MetaTable/delTableClass"),
    { params }
  );
};

//获取类别列表
export const getTableClassList = (params?: object) => {
  return http.request<resultAPI>(
    "post",
    baseUrlApi("MetaTable/getAllTableClass"),
    {
      params
    }
  );
};

//获取源表数据集
export const getTableInfoList = (data?: object) => {
  return http.request<resultAPI>("post", baseUrlApi("MetaTable/getFormList"), {
    data
  });
};

//保存源表数据
export const saveForm = (data?: object) => {
  return http.request<resultAPI>("post", baseUrlApi("MetaTable/saveForm"), {
    data
  });
};

//删除源表数据
export const delFormByIDS = (data?: object) => {
  return http.request<resultAPI>("post", baseUrlApi("MetaTable/deleteForm"), {
    data
  });
};

export const saveTableJson = (data?: object) => {
  return http.request<resultAPI>(
    "post",
    baseUrlApi("MetaTable/editFormField"),
    {
      data
    }
  );
};

//通过ID获取一个Form信息
export const getFormById = (params?: object) => {
  return http.request<resultAPI>(
    "post",
    baseUrlApi("MetaTable/getTableInfoByID"),
    {
      params
    }
  );
};

//生成表单数据
export const generateForm = (params?: object) => {
  return http.request<resultAPI>(
    "post",
    baseUrlApi("MetaTable/generateFormToTable"),
    {
      params
    }
  );
};
